﻿





using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using LightEffects;
using SpecialEffects;
using GlobalGameClasses;
using DrawableObjects.Actors.Aircrafts;

namespace DrawableObjects.Actors.Projectiles
{
    public class Plasma : Projectile
    {
        /// <summary>
        /// this class creates the different level of weapons of the weaponsystem "plasma"
        /// it also creates the enemy weapon
        /// </summary>
        private int counter = 0;

        private Plasma(float speed, int baseDamage, string strTextureModel, Matrix worldMatrix, float scaleFactor, float boundingFactor, string explosionSound)
            : base(speed, baseDamage, strTextureModel, worldMatrix, scaleFactor, boundingFactor, explosionSound)
        {
            this.strTextureModel = strTextureModel;
        }

        public static Plasma GET_PLASMA_LEVEl1()
        {
            Plasma plasma = new Plasma(1.9f, 50, "plasma_enemy", Matrix.CreateWorld(new Vector3(0, GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up), 0.1f, 1, "missileExplosion");
            PointLight light = PointLight.getPointLight(new Color(255, 100, 100), plasma);
            plasma.light = light;
            return plasma;
        }

        public static Plasma GET_PLASMA_LEVEl2()
        {
            Plasma plasma = new Plasma(1.9f, 60, "plasma_enemy", Matrix.CreateWorld(new Vector3(0, GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up), 0.15f,  1, "missileExplosion");
            PointLight light = PointLight.getPointLight(new Color(255, 120, 120), plasma);
            plasma.light = light; 
            return plasma;
        }

        public static Plasma GET_PLASMA_LEVEl3()
        {
            Plasma plasma = new Plasma(1.9f, 80, "plasma_enemy", Matrix.CreateWorld(new Vector3(0, GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up), 0.2f,  1, "missileExplosion");
            PointLight light = PointLight.getPointLight(new Color(255, 150, 150), plasma);
            plasma.light = light;
            return plasma;
        }

        public static Plasma GET_PLASMA_ENEMY(int baseDamage, Color color)
        {
            Plasma plasma = new Plasma(1.3f, 6, "plasma_enemy", Matrix.CreateWorld(new Vector3(0, GlobalGameValues.GAMEFIELD_HEIGHT, 0), Vector3.Backward, Vector3.Up), 0.1f,  1, "missileExplosion");
            PointLight light = PointLight.getPointLight(new Color(255, 110, 110), plasma);
            plasma.light = light;
            return plasma;
        }

        public override void collide(Actor actor2)
        {
            base.collide(actor2);
            if (actor2.owner != this.owner && actor2 is Aircraft)
            {
                world.addSpecialEffect(BasicExplosion.CreateSmokeExpl_Weapon(worldMatrix.Translation, Vector3.Zero, (float)GlobalGameValues.Values.gameTime.TotalGameTime.TotalMilliseconds));
                world.addSpecialEffect(BasicExplosion.CreateExpl_Plasma(worldMatrix.Translation, Vector3.Zero, (float)GlobalGameValues.Values.gameTime.TotalGameTime.TotalMilliseconds));
            }
        }

        public override Projectile Clone(Vector2 position, Vector2 direction)
        {
            Matrix newMatrix = this.worldMatrix;
            newMatrix.M41 = position.X;
            newMatrix.M43 = position.Y;
            Plasma cloned = new Plasma(this.speed, this.baseDamage, this.strTextureModel, newMatrix, this.scaleFactor,  this.boundingSphereFactor, this.explosionSound);
            cloned.direction = direction;
            cloned.standardRotation = this.standardRotation;
            return cloned;
        }

        public override void Update() 
        {
            base.Update();
            if (counter == 5) {
                Vector3 pos = worldMatrix.Translation;
                float gameTime = GlobalGameValues.Values.gameTime.TotalGameTime.Milliseconds;

                Model model;
                GlobalGameValues.Values.content.Models.TryGetValue(strTextureModel, out model);
            }
            counter++;
            counter %= 5;
        }
    }
}

